<template>
	<view class="container">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="物品管理" back-icon-color='#333333' height="50" :border-bottom="false">
		</u-navbar>
		<view class="list">
			<view class="equipment">
				<text>{{name}}</text>
			</view>
			<view class="step">
				<view class="first_step" v-for="(item,index) in historyList" :key="index">
					<view class="left">
						<image src="../../static/tupian129.png" mode="widthFix"></image>
						<text></text>
					</view>
					<view class="right">
						<view class="emplyees">
							<text>{{item.title}}</text>
						</view>
						<view class="staff">
							<text>{{item.onset}}</text>
							<image src="../../static/tupian148.png" mode="widthFix"></image>
							<text>{{item.endset}}</text>
						</view>
						<view class="time">
							<text>{{item.startDate}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import request from '../../request.js'
	import time from '../../time.js'
	export default {
		data() {
			return {
				num: 3,
				history_list: [],
				name:'摄影机',
			}
		},
		onLoad(option) {
			if (option) {
				this.num = option.id;
				this.name=option.name;
			}
			this.goodsLists();
		},
		computed: {
			historyList() {
				if (this.history_list) {
					this.history_list.forEach(item => {
						this.$set(item, 'startDate', time.format(item.create_time));
						if (item.text) {
							let length = item.text.indexOf('>');
							this.$set(item, 'onset', item.text.substr(0, length));
							this.$set(item, 'endset', item.text.substr(length + 1, item.text.length));
						} else {
							this.$set(item, 'onset', '');
							this.$set(item, 'endset', '');
						}
					})
					return this.history_list;
				} else {
					return [];
				}
			}
		},
		methods: {
			goodsLists() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/goods/goodsHistory',
					method: 'post',
					data: {
						goods_id: _this.num,
					},
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data.data);
							_this.history_list = res.data.data;
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		background: #F2F2F2;
		overflow: hidden;

		.list {
			width: 710rpx;
			border-radius: 12rpx;
			background: #fff;
			margin-left: 20rpx;
			margin-top: 20rpx;

			.equipment {
				width: 94%;
				margin-left: 3%;
				height: 120rpx;
				display: flex;
				justify-content: flex-start;

				text {
					&:nth-child(1) {
						font-size: 30rpx;
						color: #333333;
						margin-top: 28rpx;
						font-weight: bolder;
					}
				}
			}

			.step {
				width: 94%;
				margin-left: 3%;
				overflow: hidden;

				.first_step {
					width: 100%;
					height: 180rpx;
					display: flex;
					justify-content: flex-start;

					.left {
						width: 60rpx;
						display: flex;
						flex-direction: column;
						align-items: flex-start;
						justify-content: flex-start;

						image {
							&:nth-child(1) {
								width: 30rpx;
							}
						}

						text {
							&:nth-child(2) {
								width: 2rpx;
								height: 150rpx;
								background: #ccc;
								margin-left: 15rpx;
							}
						}
					}

					.right {
						width: 620rpx;

						.emplyees {
							width: 100%;
							height: 32rpx;
							display: flex;
							align-items: center;
							justify-content: flex-start;

							text {
								&:nth-child(1) {
									font-size: 30rpx;
									color: #333333;
								}
							}
						}

						.staff {
							width: 100%;
							height: 51rpx;
							display: flex;
							justify-content: flex-start;

							text {
								font-size: 26rpx;
								color: #333333;
								margin-top: 19rpx;

								&:nth-child(1) {
									width: 240rpx;
									overflow:hidden;
								}

								&:nth-child(3) {
									margin-left: 25rpx;
								}
							}

							image {
								&:nth-child(2) {
									margin-top: 23rpx;
									width: 25rpx;
								}
							}
						}

						.time {
							width: 100%;
							height: 48rpx;
							display: flex;
							justify-content: flex-start;

							text {
								font-size: 22rpx;
								color: #cccccc;
								margin-top: 19rpx;

								&:nth-child(1) {
									width: 100%;
								}

								&:nth-child(2) {}
							}
						}

					}

				}

				.second_step {
					width: 100%;
					height: 180rpx;
					display: flex;
					justify-content: flex-start;

					.left {
						width: 60rpx;
						display: flex;
						flex-direction: column;
						align-items: flex-start;
						justify-content: flex-start;

						image {
							&:nth-child(1) {
								width: 30rpx;
							}
						}

						text {
							&:nth-child(2) {
								width: 2rpx;
								height: 150rpx;
								background: #ccc;
								margin-left: 15rpx;
							}
						}
					}

					.right {
						width: 620rpx;

						.emplyees {
							width: 100%;
							height: 32rpx;
							display: flex;
							align-items: center;
							justify-content: flex-start;

							text {
								&:nth-child(1) {
									font-size: 30rpx;
									color: #333333;
								}
							}
						}

						.staff {
							width: 100%;
							height: 51rpx;
							display: flex;
							justify-content: flex-start;

							text {
								font-size: 26rpx;
								color: #333333;
								margin-top: 19rpx;

								&:nth-child(1) {
									width: 280rpx;
								}

								&:nth-child(3) {
									margin-left: 25rpx;
								}
							}

							image {
								&:nth-child(2) {
									margin-top: 23rpx;
									width: 25rpx;
								}
							}
						}

						.time {
							width: 100%;
							height: 48rpx;
							display: flex;
							justify-content: flex-start;

							text {
								font-size: 22rpx;
								color: #cccccc;
								margin-top: 19rpx;

								&:nth-child(1) {
									width: 140rpx;
								}

								&:nth-child(2) {}
							}
						}

					}
				}

				.third_step {
					width: 100%;
					height: 180rpx;
					display: flex;
					justify-content: flex-start;

					.left {
						width: 60rpx;
						display: flex;
						flex-direction: column;
						align-items: flex-start;
						justify-content: flex-start;

						image {
							&:nth-child(1) {
								width: 30rpx;
							}
						}

						text {
							&:nth-child(2) {
								width: 2rpx;
								height: 150rpx;
								background: #ccc;
								margin-left: 15rpx;
							}
						}
					}

					.right {
						width: 620rpx;

						.emplyees {
							width: 100%;
							height: 32rpx;
							display: flex;
							align-items: center;
							justify-content: flex-start;

							text {
								&:nth-child(1) {
									font-size: 30rpx;
									color: #333333;
								}
							}
						}

						.staff {
							width: 100%;
							height: 51rpx;
							display: flex;
							justify-content: flex-start;

							text {
								font-size: 26rpx;
								color: #333333;
								margin-top: 19rpx;

								&:nth-child(1) {
									width: 280rpx;
								}

								&:nth-child(3) {
									margin-left: 25rpx;
								}
							}

							image {
								&:nth-child(2) {
									width: 25rpx;
									margin-top: 23rpx;
								}
							}
						}

						.time {
							width: 100%;
							height: 48rpx;
							display: flex;
							justify-content: flex-start;

							text {
								font-size: 22rpx;
								color: #cccccc;
								margin-top: 19rpx;

								&:nth-child(1) {
									width: 140rpx;
								}

								&:nth-child(2) {}
							}
						}

					}
				}
			}

		}
	}
</style>
